package com.nifostasky.comic.business.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.client.utils.JSONUtils;
import com.nifostasky.comic.common.utils.JsonUtil;
import com.nifostasky.comic.entitys.CoDetailedInfo;
import com.nifostasky.comic.service.ShellService;
import com.nifostasky.comic.vos.JsonResult;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
import java.util.Objects;

@RestController
@RequestMapping("/ShellController")
@Api(tags = "执行py程序")
@Slf4j
@ApiSort(9999)
@AllArgsConstructor
public class ShellController {
    private ShellService shellService;
    /**
     * 获取主页漫画信息
     */
    @ApiOperation("获取主页漫画信息")
    @GetMapping("/searchMainPageComic")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pyId", value = "python文件id", dataType = "Int", required = true),
    })
    @ApiOperationSupport(order = 1)
    public JsonResult searchMainPageComic(Long pyId){
        return new JsonResult(shellService.searchMainPageComic(pyId));
    }

    /**
     * 获取搜索漫画
     */
    @ApiOperation("获取搜索漫画")
    @GetMapping("/searchComic")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageIndex", value = "页数", dataType = "Int", required = true),
            @ApiImplicitParam(name = "keyword", value = "关键字", dataType = "Int", required = true),
            @ApiImplicitParam(name = "pyId", value = "python文件id", dataType = "Int", required = true)
    })
    @ApiOperationSupport(order = 2)
    public JsonResult searchComic(Integer pageIndex, String keyword,Long pyId){
        return new JsonResult(shellService.searchComic(pageIndex,keyword,pyId));
    }

    /**
     * 获取漫画详情
     */
    @ApiOperation("获取漫画详情")
    @GetMapping("/detailComic")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageIndex", value = "页数", dataType = "Int", required = true),
            @ApiImplicitParam(name = "url", value = "python文件url", dataType = "Int", required = true),
            @ApiImplicitParam(name = "pyId", value = "python文件id", dataType = "Int", required = true)
    })
    @ApiOperationSupport(order = 3)
    public JsonResult detailComic(Integer pageIndex,String url,Long pyId){
        return new JsonResult(shellService.detailComic(pageIndex,url,pyId));
    }

    /**
     * 获取某章节图片信息
     */
    @ApiOperation("获取某章节图片信息")
    @GetMapping("/pictureComic")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "url", value = "python文件url", dataType = "Int", required = true),
            @ApiImplicitParam(name = "pyId", value = "python文件id", dataType = "Int", required = true)
    })
    @ApiOperationSupport(order = 4)
    public JsonResult pictureComic(String url,Long pyId){
        return new JsonResult(shellService.pictureComic(url,pyId));
    }
}
